- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsource.cpp
39 lines (35 loc) · 880 Bytes
/
source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#using <system.dll>
#using <System.Data.dll>
#using <System.Drawing.dll>
#using <system.windows.forms.dll>
usingnamespaceSystem;
usingnamespaceSystem::Data;
usingnamespaceSystem::ComponentModel;
usingnamespaceSystem::Windows::Forms;
public ref classForm1: publicForm
{
protected:
bool myDataIsSaved;
// <Snippet1>
private:
// Call this method from the InitializeComponent() method of your form
voidOtherInitialize()
{
this->Closing += gcnew CancelEventHandler( this, &Form1::Form1_Cancel );
this->myDataIsSaved = true;
}
voidForm1_Cancel( Object^ /*sender*/, CancelEventArgs^ e )
{
if ( !myDataIsSaved )
{
e->Cancel = true;
MessageBox::Show( "You must save first." );
}
else
{
e->Cancel = false;
MessageBox::Show( "Goodbye." );
}
}
// </Snippet1>
};